home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / TEMPCONV.MOD < prev    next >
Text File  |  1989-01-18  |  2KB  |  66 lines

  1.                                        (* Chapter 4 - Program 4 *)
  2.  
  3. (* This program is a good example of proper formatting, it is   *)
  4. (* easy to read and very easy to understand.  It should be a    *)
  5. (* snap to update a program that is well written like this. You *)
  6. (* should begin to develop good formatting practice early in    *)
  7. (* your programming career.                                     *)
  8.  
  9. MODULE TempConv;
  10.  
  11. FROM InOut IMPORT WriteString, WriteInt, WriteLn;
  12.  
  13. VAR Count      : INTEGER;   (* a variable used for counting     *)
  14.     Centigrade : INTEGER;   (* the temperature in centigrade    *)
  15.     Fahrenheit : INTEGER;   (* the temperature in fahrenheit    *)
  16.  
  17. BEGIN
  18.  
  19.    WriteString("Fahrenheit to Centigrade temperature table");
  20.    WriteLn;
  21.    WriteLn;
  22.  
  23.    FOR Count := -2 TO 12 DO
  24.       Centigrade := 10 * Count;
  25.       Fahrenheit := 32 + Centigrade *9 DIV 5;
  26.       WriteString("   C =");
  27.       WriteInt(Centigrade,5);
  28.       WriteString("     F =");
  29.       WriteInt(Fahrenheit,5);
  30.       IF Centigrade = 0 THEN
  31.          WriteString("   Freezing point of water");
  32.       END;
  33.       IF Centigrade = 100 THEN
  34.          WriteString("   Boiling point of water");
  35.       END;
  36.       WriteLn;
  37.    END; (* of main loop *)
  38.  
  39. END TempConv.
  40.  
  41.  
  42.  
  43.  
  44. (* Result of execution
  45.  
  46. Fahrenheit to Centigrade temperature table
  47.  
  48.    C =  -20     F =    -4
  49.    C =  -10     F =    14
  50.    C =    0     F =    32   Freezing point of water
  51.    C =   10     F =    50
  52.    C =   20     F =    68
  53.    C =   30     F =    86
  54.    C =   40     F =   104
  55.    C =   50     F =   122
  56.    C =   60     F =   140
  57.    C =   70     F =   158
  58.    C =   80     F =   176
  59.    C =   90     F =   194
  60.    C =  100     F =   212   Boiling point of water
  61.    C =  110     F =   230
  62.    C =  120     F =   248
  63.  
  64. *)
  65.  
  66.